home *** CD-ROM | disk | FTP | other *** search
/ PC Media 22 / PC MEDIA CD22.iso / share / prog / rodent / 2.asm < prev    next >
Encoding:
Assembly Source File  |  1995-08-15  |  4.1 KB  |  212 lines

  1. .model small
  2. .stack 0100h
  3. .code
  4. start:
  5.  
  6. ;-------initialize the mouse
  7. xor     ax, ax
  8. int     33h
  9.  
  10. ;-------check to see if mouse is installed
  11. cmp     ax,0000h
  12.  
  13. ;-------proceed if mouse driver loaded
  14. jnz     it_lives
  15.  
  16. ;-------if not, then exit
  17. jmp     error
  18.  
  19. ;-------begin mouse routine
  20. it_lives:
  21.  
  22. ;-------initialize our data area
  23. mov     ax, @data
  24. mov     ds, ax
  25. mov     es, ax
  26.  
  27. ;-------Make sure we're in video mode 3 (text mode)
  28. mov     ah, 0
  29. mov     al, 3
  30. int     10h
  31.  
  32. ;-------call routine to clear the screen, display message,
  33. ;        and hide screen cursor
  34. call    ts_clear
  35. call    exit_message
  36. call    cursor_hide 
  37.  
  38. ;-------make arrow shape in font tables
  39. call    change_font
  40.  
  41. ;-------set boundaries for, and make mouse cursor visible on screen 
  42. call    boundaries
  43. mov     ax, 0001h
  44. int     33h
  45.  
  46. ;-------set cursor shape to take on our newly defined font (arrow)
  47. mov     ax, 0ah
  48. mov     bx, 00h
  49. mov     cx, 00h
  50. mov     dx, 1c02h
  51. int     33h
  52.  
  53. ;-------wait for keypress
  54. mov     ah, 00h
  55. int     16h
  56.  
  57. ;-------hide mouse cursor and clear the screen
  58. mov     ax, 0002h
  59. int     33h
  60. call    ts_clear
  61.  
  62. jmp     exit
  63. ;-------no mouse loaded so, exit with error message
  64. error:
  65. mov     ax, @data
  66. mov     ds, ax
  67. mov     dx, offset err_message
  68. mov     ah, 09h
  69. int     21h
  70.  
  71. ;-------terminate program
  72. exit:
  73. mov     ah, 04ch
  74. int     21h
  75.  
  76. ;-------procedure to clear text screen
  77. ts_clear proc near
  78.  
  79. push    ax
  80. push    cx
  81. push    es
  82. push    di
  83.  
  84. mov     ax, 0b800h
  85. mov     es, ax
  86. mov     di, 0000h
  87. mov     ax, 1700h
  88. mov     cx, 0fa0h
  89. cld
  90. repz
  91. stosw
  92.  
  93. pop     di
  94. pop     es
  95. pop     cx
  96. pop     ax
  97. ret
  98. ts_clear endp
  99.  
  100. ;-------procedure to create arrow in font-table
  101. change_font proc near
  102.  
  103. ;-------save the registers that we'll be changing
  104. pushf
  105. push    ax
  106. push    bx
  107. push    cx
  108. push    dx
  109. push    ds
  110. push    es
  111. push    bp
  112.  
  113. ;-------BIOS routine to load user defined character font
  114. mov     ax, 1100h       ; BIOS  function  to  load  user_specified  font 
  115. mov     bh, 14          ; Number of bytes_per_character in table (below)
  116. mov     bl, 0           ; Character generator RAM block 
  117. mov     cx, 1           ; Number  of  character  we  are going to change
  118. mov     dx, 2           ; First  (only)  character  we   are   changeing
  119. mov     bp, offset figure       ; Address   character  generation  table
  120. int     10h
  121.  
  122. ;-------return saved registers
  123. pop     bp
  124. pop     es
  125. pop     ds
  126. pop     dx
  127. pop     cx
  128. pop     bx
  129. pop     ax
  130. popf
  131.  
  132. ret
  133. endp    change_font 
  134.  
  135. ; display exit message
  136. exit_message proc near
  137.  
  138. push    ax
  139. push    dx
  140. mov     dx, offset quit
  141. mov     ah, 09h
  142. int     21h
  143. pop     dx
  144. pop     ax
  145. ret
  146. exit_message endp
  147.  
  148. ; hide screen cursor
  149. cursor_hide proc near
  150.  
  151. push    ax
  152. push    bx
  153. push    dx
  154. mov     ah,02h
  155. mov     bh,0
  156. mov     dh, 25
  157. mov     dl, 0
  158. int     10h
  159. pop     dx
  160. pop     bx
  161. pop     ax
  162. ret     
  163. cursor_hide endp
  164.  
  165. ; set upper mouse boundaries
  166. boundaries proc near
  167.  
  168. push    ax
  169. push    cx
  170. push    dx
  171. mov     ax, 0008h
  172. mov     cx, 8
  173. mov     dx, 199
  174. int     33h
  175. pop     dx
  176. pop     cx
  177. pop     ax
  178. ret
  179. boundaries endp
  180.  
  181. ;-------Data Area------------------------------------------------------------
  182. .data
  183. quit            db      "                             -- Hit any key to exit -- $"
  184. err_message     db      12 dup(10, 13)
  185.                 db      "                 A mouse drive must first be loaded" 
  186.                 db      " in memory"
  187.                 db      10, 13
  188.                 db      "                         prior to running this prog"
  189.                 db      "ram!"
  190.                 db      12 dup(10, 13)
  191.                 db      "$"
  192.  
  193. figure  db        00000000b     ; arrow to replace normal ascii character
  194.         db        10000000b
  195.         db        11000000b
  196.         db        11100000b
  197.         db        11110000b
  198.         db        11111000b
  199.         db        11111100b
  200.         db        11111110b
  201.         db        11111111b
  202.         db        00011000b
  203.         db        00001100b
  204.         db        00000110b
  205.         db        00000000b
  206.         db        00000000b
  207.  
  208.  
  209.  
  210. end start
  211.  
  212.